import { Component, OnInit, ViewChild, ViewContainerRef, ComponentRef, ComponentFactoryResolver } from '@angular/core';
import { StopFundPageComponent } from "../content/stop-fund-page/stop-fund-page.component";
import { StopfundService } from "./stopfund.service";

@Component({
  selector: 'app-stopfund',
  templateUrl: './stopfund.component.html',
  styleUrls: ['./stopfund.component.scss'],
  providers: [StopfundService]
})
export class StopfundComponent implements OnInit {
  // 终止后资金流水页面
  @ViewChild("stopFundPage", { read: ViewContainerRef })
  stopFundPage: ViewContainerRef;
  stopFundPageComponent: ComponentRef<StopFundPageComponent>;

  constructor(
    public stopfundService: StopfundService,
    public resolver: ComponentFactoryResolver
  ) { }

  ngOnInit() {
    this.showStopfundPage();
  }
  // 终止后资金流水页面
  showStopfundPage() {
    if (this.stopFundPageComponent && this.stopFundPageComponent.instance) {
      this.stopFundPageComponent.destroy();
    }
    const stopFundPageComponent = this.resolver.resolveComponentFactory(StopFundPageComponent);
    this.stopFundPageComponent = this.stopFundPage.createComponent(stopFundPageComponent);
  }
}
